<?php

	class ServiceDataAccessMySQL implements iServiceDataAccess {
		
		public function buildObject($result) {
			
			$service = new Service();
			
			$service->setServiceId($result->serviceId);
			$service->setName($result->description);
			
			return $service;
		}
		
		public function select($service, $dataBaseConnection) {
			$resultArray = array();
			
			if ($service->getServiceId() != null){
				$parameters["SERVICEID"] = $service->getServiceId();
			} else {
				$parameters["SERVICEID"] = "NULL";
			}
			
			if ($service->getName() != null){
				$parameters["NAME"] = $service->getName();
			}else {
				$parameters["NAME"] = "NULL";
			}
			
			$query = buildQuery("querySelectService", $parameters);
			if (!is_bool($query)) {
				if ($result = $dataBaseConnection->query($query)) {
					while($row = mysql_fetch_object($result)) {
						array_push($resultArray, $this->buildObject($row));	
					}
					return $resultArray;	
				}
				else {
					return NULL;
				}
			} else {
				return NULL;
			}
		}
		
	}

?>